package com.fowo.api.inventory.model;

import com.fowo.api.inventory.entity.*;
import com.fowo.api.inventory.model.form.InventoryStorageBaseVo;
import com.fowo.api.inventory.model.form.InventoryStorageFormVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@Schema(title = "库存服务返回实体")
public class InventoryListReturnVo {
    @Schema(title = "操作添加的库存记录 ID 列表")
    private List<Long> addIds;
    @Schema(title = "操作更新的库存记录 ID 列表")
    private List<Long> updateIds;
    @Schema(title = "操作删除的库存记录 ID 列表")
    private List<Long> removeIds;
    @Schema(title = "操作产生的变更记录 ID 列表")
    private List<Long> variationIds;


    @Schema(title = "库存添加 调拨会有")
    private InventoryStorageBaseVo inventoryStorageVo;


    @Schema(title = "操作添加库存流水批量添加")
    private InventoryVariation inventoryVariations;

    @Schema(title = "操作出库库存流水批量添加")
    private List<InventoryVariation> insertInventoryVariations;
    @Schema(title = "操作添加仓位流水批量添加 ")
    private List<InventoryPlacementVariation> inventoryPlacementVariations;

    @Schema(title = "库龄表添加")
    private InventoryBatchNo inventoryBatchNo;
    @Schema(title = "库龄表修改")
    private List<InventoryBatchNo> updateInventoryBatchNoList;
    @Schema(title = "库存添加")
    private Inventory inventory;
    @Schema(title = "库存修改")
    private List<Inventory> updateInventoryList;
    @Schema(title = "仓位添加")
    private List<InventoryPlacement> inventoryPlacement;
    @Schema(title = "仓位修改")
    private List<InventoryPlacement> updateInventoryPlacementList;

    @Schema(title = "库龄表添加 调拨会有")
    private List<InventoryBatchNo> insertInventoryBatchNo;
    @Schema(title = "库存添加 调拨会有")
    private List<Inventory> insertInventory;


    /**
     * 将另一个返回合并到当前返回
     *
     * @param other 另一个返回
     * @return 自身
     */
    public InventoryListReturnVo add(InventoryListReturnVo other) {
        if (other.addIds != null) {
            if (addIds == null) {
                addIds = new ArrayList<>();
            }
            addIds.addAll(other.addIds);
        }
        if (other.updateIds != null) {
            if (updateIds == null) {
                updateIds = new ArrayList<>();
            }
            updateIds.addAll(other.updateIds);
        }
        if (other.removeIds != null) {
            if (removeIds == null) {
                removeIds = new ArrayList<>();
            }
            removeIds.addAll(other.removeIds);
        }
        if (other.variationIds != null) {
            if (variationIds == null) {
                variationIds = new ArrayList<>();
            }
            variationIds.addAll(other.variationIds);
        }
        return this;
    }

}
